package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.DepartmentDao;
import cn.gson.springboot.model.mapper.DepartmentMapper;
import cn.gson.springboot.model.pojos.Department;
import cn.gson.springboot.model.pojos.FunctionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class DepartmentService {
    @Autowired
    DepartmentDao deptDao;
    @Autowired
    DepartmentMapper departmentMapper;

    //查询所有部门
      public List<Department> findAllDept(){
         return departmentMapper.findAllDept();
     }

    public List<Department> findDept(Integer deptId){
          return departmentMapper.findDept(deptId);
    }

    public void saveDept(Department department) {
          deptDao.save(department);
    }

    public List<Department> findDepts() {
          return departmentMapper.findDepts();
    }

    public List<Department> findDeptEmp(){
          return departmentMapper.findDeptEmp();
    }

    public void deleteDept(Integer deptId){
          deptDao.deleteById(deptId);
    }
}
